<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('提现审核列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId">
            <div class="form-inline">
                <input type="text" class="form-control mr-1" name="searchKey" placeholder="用户id/名称">
                <select name="type" class="form-control mr-1">
                    <option value="">类型</option>
                    <option value="TEACHER">用户提现</option>
                    <option value="COMPANY">机构提现</option>
                </select>
                <select name="status" class="form-control mr-1">
                    <option value="">状态</option>
                    <option value="-1">驳回</option>
                    <option value="0">待审核</option>
                    <option value="1">已支付</option>
                    <option value="2">未支付</option>
                </select>
                <button type="button" class="btn btn-primary mr-1" onclick="$.table.search()">
                    <i class="fa fa-search"></i>
                    搜索
                </button>
                <button type="button" class="btn btn-default" onclick="$.form.reset()">
                    <i class="fa fa-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
    <table id="bootstrap-table" class="table-striped"></table>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    $(function() {
        var options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: "/cashapply/list.json",
            modalName: "账户历史",
            columns: [
                {
                    field: 'id',
                    title: 'id'
                },
                {
                    field: 'infoName',
                    title: '名称',
                    formatter: function (value, row, index) {
                        if (row.type === "COMPANY") {
                            return row.infoName + '(<span class="text-blue">compnayId:' + row.infoId + '</span>)';
                        } else {
                            return row.infoName + '(<span class="text-blue">userId:' + row.infoId + '</span>)';
                        }
                    }
                },
                {
                    field: 'type',
                    title: '类型',
                    width: 100,
                    formatter: function (value, row, index) {
                        if (row.type === "TEACHER") {
                            return '<span class="label label-success">用户提现</span>';
                        } else if (row.type === "COMPANY") {
                            return '<span class="label label-primary">机构提现</span>'
                        } else {
                            return '-';
                        }
                    }
                },
                {
                    field: 'amount',
                    title: '提取金额',
                    formatter: function (value, row, index) {
                        return row.amount / 100;
                    }
                },
                {
                    field: 'bankName',
                    title: '开户银行'
                },
                {
                    field: 'bankCardName',
                    title: '开户人'
                },
                {
                    field: 'bankCardNumber',
                    title: '银行卡号'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        switch (row.status) {
                            case -1:
                                return '<span class="badge badge-danger">驳回</span>';
                            case 0:
                                return '<span class="badge badge-warning">未审核</span>';
                            case 1:
                                return '<span class="badge badge-success">未支付</span>';
                            case 2:
                                return '<span class="badge badge-primary">已支付</span>';
                            default:
                                return '-';
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '申请时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    width: 120,
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="cashApplyInfo(\'' + row.id + '\')"><i class="fa fa-search"></i>详情</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //详情页
    function cashApplyInfo(id) {
        layer.open({
            type: 2,
            title: "详情",
            area: ['90%', '92%'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            content: "/cashapply/view.html?id=" + id,
            shadeClose: true,
        });
    }
</script>
</body>
</html>